#include "esl_dispatcher.h"
#include <iostream>

bool ESLDispatcher::connect()
{
    esl_status_t r = ESL_FAIL;
    esl_port_t port = (esl_port_t) _port;

    r = esl_connect(_handle, _host, port, _user, _pass);
    return (r == ESL_SUCCESS ? true : false);
}

bool ESLDispatcher::sendEvent(const char *command)
{
    esl_send_recv(_handle, command);

    if (_handle->last_sr_event && _handle->last_sr_event->body) {
        std::cout << _handle->last_sr_event->body << std::endl;
    } else {
        std::cout << _handle->last_sr_reply << std::endl;
    }   

    return true;
}
